<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>对象的创建使用练习</title>
		<script type="text/javascript">
			let stu1 = {
				 sutName : "张家鹏",
				 sutAge : 48,
				 stuSex : "男",
				fun:function(){
					console.log("123");
				}
			};
			
			let stu2 = {
				 sutName : "黄书丹",
				 sutAge : 38,
				 stuSex : "男",
				fun:function(){
					console.log("123");
				}
			};
			
			let stu3 = {
				 sutName : "杨可萍",
				 sutAge : 19,
				 stuSex : "女",
				fun:function(){
					console.log("123");
				}
			};
			
			let student = [];
			student.push(stu1);
			student.push(stu2);
			student.push(stu3);
			
			console.log(student);
			let ageSum = 0;
			let maxAge = 0;
			let maxAge_index = 0;
			for (var i = 0; i < student.length; i++) {
				ageSum += student[i].sutAge;
				if(student[i].sutAge > maxAge) {
					maxAge = student[i].sutAge;
					maxAge_index = i;
				}
			}
			console.log(ageSum);
			console.log(student[maxAge_index].sutName);
			
			let arr = [];
			let arr2 = [];
			for (var i = 0; i < student.length; i++) {
				if(student[i].stuSex == "男") {
					arr.push(student[i]);
				} else if(student[i].stuSex == "女") {
					arr2.push(student[i]);
				}
			}
			console.log(arr);
			console.log(arr2);
		</script>
	</head>
	<body>
	</body>
</html>